package com.cd.common.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @description 菜单权限表 ||  || 
* @author admin
* @date 2024-03-25
*/
@Entity
@Data
@Table(name = "sys_menu")
public class SysMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    //@Comment("菜单ID")
    //自增
    @Column(name = "menu_id", nullable = false )
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long menuId;

    //@Comment("菜单名称")
    @Column(name = "menu_name", nullable = false )
    private String menuName;

    //@Comment("父菜单ID")
    @Column(name = "parent_id" )
    private Long parentId;


    //@Comment("显示顺序")
    @Column(name = "order_num" )
    private Integer orderNum;

    //@Comment("路由地址")
    @Column(name = "path" )
    private String path;

    //@Comment("组件路径")
    @Column(name = "component" )
    private String component;

    //@Comment("路由参数")
    @Column(name = "query" )
    private String query;

    //@Comment("是否为外链（0是 1否）")
    @Column(name = "is_frame" )
    private String isFrame;

    //@Comment("是否缓存（0缓存 1不缓存）")
    @Column(name = "is_cache" )
    private String isCache;

    //@Comment("菜单类型（M目录 C菜单 F按钮）")
    @Column(name = "menu_type" )
    private String menuType;

    //@Comment("菜单状态（0显示 1隐藏）")
    @Column(name = "visible" )
    private String visible;

    //@Comment("菜单状态（0正常 1停用）")
    @Column(name = "status" )
    private String status;

    //@Comment("权限标识")
    @Column(name = "perms" )
    private String perms;

    //@Comment("菜单图标")
    @Column(name = "icon" )
    private String icon;

    //@Comment("创建者") 魔改 如果为business 则为可售卖
    @Column(name = "create_by" )
    private String createBy;

    //@Comment("创建时间")
    @Column(name = "create_time" )
    private Date createTime;

    //@Comment("更新者")
    @Column(name = "update_by" )
    private String updateBy;

    //@Comment("更新时间")
    @Column(name = "update_time" )
    private Date updateTime;

    //@Comment("备注")
    @Column(name = "remark" )
    private String remark;

    @Transient//不会存到数据库
    private List<SysMenu> children =new ArrayList<>();
    @Transient//后续 可能有问题 要重写一下
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    public Map<String, Object> getParams()
    {
        if (params == null)
        {
            params = new HashMap<>();
        }
        return params;
    }

}

